<template>
  <div class="layui-container fly-marginTop fly-user-main">
    <UserNav :current=3></UserNav>
  <div class="fly-panel fly-panel-user" pad20>
    <!--
    <div class="fly-msg" style="margin-top: 15px;">
      您的邮箱尚未验证，这比较影响您的帐号安全，<a href="activate.html">立即去激活？</a>
    </div>
    -->
    <div class="layui-tab layui-tab-brief" lay-filter="user">
      <ul class="layui-tab-title" id="LAY_mine">
        <li data-type="mine-jie" lay-id="index" @click="post" :class="{'layui-this':0 == current}">我发的帖（<span>{{data.count}}</span>）</li>
        <li data-type="collection" data-url="/collection/find/" lay-id="collection" @click="collection" :class="{'layui-this':1 == current}">我收藏的帖（<span>{{cdata.count}}</span>）</li>
      </ul>
      <div class="layui-tab-content" style="padding: 20px 0;">
        <div class="layui-tab-item" :class="{'layui-show':0 == current}">
          <ul class="mine-view jie-row">
            <li v-for="(item) in data.rows" :key="item.id">
              <a class="jie-title" :href="'/post/'+item.id" target="_blank">{{item.title}}</a>
              <i>2017/3/14 上午8:30:00</i>
              <a class="mine-edit" :href="'/post/'+item.id">编辑</a>
              <em>{{item.view_count}}阅/{{item.comment_count}}答</em>
            </li>
          </ul>
          <div id="LAY_page"></div>
        </div>
        <div class="layui-tab-item" :class="{'layui-show':1 == current}">
          <ul class="mine-view jie-row">
            <li  v-for="(item) in cdata.rows" :key="item.id">
              <a class="jie-title" href="../jie/detail.html" target="_blank">{{item.title}}</a>
              <i>收藏于{{item.create_date}}</i>  
            </li>
          </ul>
          <div id="LAY_page1"></div>
        </div>
      </div>
    </div>
  </div>
</div>
</template>

<script>
import UserNav from './UserNav.vue'
import request from '@/utils/request'
export default {
  components: {
     UserNav,
  },
  data() {
    return {
      id: 0, //ID
      title: "", //标题
      address: "bbs.100txy.com", //地址
      data: {}, //帖子
      cdata: {}, //帖子
      current: 0
    };
  },
  mounted(){
    console.log(this.$route)
    console.log("id:",this.$route.params.id)
    this.getPosts() //获取历史发布帖子
  },
  setup(){
    console.log("setup start")
    myFn()
    function myFn(){
      console.log("aaa");
    }
    return {
      myFn
    }
  },
  methods: {
    //获取历史发布帖子
    getPosts() {
      const params = {
        params: {
        }
      }
      request.get('/micro-bbs/v2/members/posts', params).then((res) => {
        const { code, data } = res
        // this.notifySucceed(message);
        if (code === 200) {
          this.title = data.title
          this.data = data.postData
          this.address = data.address
          this.cdata = data.collectData
        }
      })
    },
    //我发布的贴
    post(){
      this.current = 0
    },
    //我收藏的贴
    collection(){
      this.current = 1
    }

  }
}
</script>